{include file='common/head.html'}

<div class="layui-body">
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="t1">访客记录</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th>序号</th>
                            <th>用户IP</th>
                            <th>操作系统</th>
                            <th>浏览器</th>
                            <th>地区/运营商</th>
                            <th>访问页面</th>
                            <th>时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach $syslogs(key,value,num)}
                        <tr>
                            <td>[num]</td>
                            <td>[value->user_ip]</td>
                            <td>[value->user_os]</td>
                            <td>[value->user_bs]</td>
                            <td>[value->user_area]</td>
                            <td><a href="[value->log_url]" target="_blank">[value->log_url]</a></td>
                            <td>[value->create_time]</td>
                            <td>
                                {if($value->status==1)}
                                <a data-url="{url./admin/Blacklog/toblack/status/0/id/'.$value->id.'}"  data-formcheck="{$formcheck}" data-ip="[value->user_ip]" onclick="blacklog(this)" class="layui-btn layui-btn-xs layui-btn-danger" title="拉黑ip">拉黑ip</a>
                                {else}
                                <a data-url="{url./admin/Blacklog/toblack/status/1/id/'.$value->id.'}"  data-formcheck="{$formcheck}" data-ip="[value->user_ip]" onclick="blacklog(this)" class="layui-btn layui-btn-xs layui-btn-normal" title="恢复ip">恢复ip</a>
                                {/if}
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
                {if(session('ucode')==10001)}
                <a href="{url./admin/Blacklog/clear}" class="layui-btn layui-btn-sm"  onclick='return confirm("您确定要清空么？")'>清空日志</a>
                {/if}
                <div class="page">{$pagebar}</div>
            </div>
        </div>
    </div>

</div>
<script>
    //blacklog
    function blacklog(that) {
        var url = $(that).data('url');
        var ip = $(that).data('ip');
        var formcheck = $(that).data('formcheck');
        layer.confirm('你确定要拉黑这个ip吗？', [], function (index, layero) {
            $.ajax({
                type: 'post',
                url: url,
                data:{ip:ip,'formcheck':formcheck},
                dataType: 'json',
                success: function (res, status) {
                     layer.close(index);
                    if(res.code ==1){
                        layer.alert(res.data,function(alert_index){
                            location.href = location.href; 
                            layer.close(alert_index);
                        });
                    }else{
                        layer.alert(res.data);
                    }
                },
                error: function (xhr, status, error) {
                     layer.close(index);
                    layer.alert("发生错误!");
                }
            });
            
        }, function (index) {
            layer.close(index);
        });

    }
</script>
{include file='common/foot.html'}